/*  1:   */package com.java.diagnostics.visualizer.recommender.nativeMemory;
/*  2:   */
/*  3:   */import com.java.diagnostics.visualizer.data.AggregateData;
/*  4:   */import com.java.diagnostics.visualizer.data.StructuredData;
/*  5:   */import com.java.diagnostics.visualizer.data.TupleData;
/*  6:   */import com.java.diagnostics.visualizer.parser.vgc.constants.VGCAxes;
/*  7:   */import com.java.diagnostics.visualizer.recommender.Recommendation;
/*  8:   */import com.java.diagnostics.visualizer.recommender.RecommendationBase;
/*  9:   */import com.java.diagnostics.visualizer.recommender.util.RecommendationLabels;
/* 10:   */import java.util.Collection;
/* 11:   */import java.util.Iterator;
/* 12:   */import java.util.Map;
/* 13:   */
/* 27:   */public class LookForNativeMemoryExhaustion
/* 28:   */  extends RecommendationBase
/* 29:   */  implements Recommendation
/* 30:   */{
/* 31:31 */  private String platformName = null;
/* 32:   */  
/* 33:   */  public void recommend(AggregateData data)
/* 34:   */  {
/* 35:35 */    StructuredData platform = data.getStructuredData("platform");
/* 36:   */    
/* 37:37 */    if (platform != null) {
/* 38:38 */      Map info = platform.getContents();
/* 39:39 */      if (info.size() > 0) {
/* 40:40 */        Iterator lines = info.values().iterator();
/* 41:41 */        while (lines.hasNext()) {
/* 42:42 */          this.platformName = ((String)lines.next());
/* 43:   */        }
/* 44:   */      }
/* 45:   */    }
/* 46:   */    
/* 47:47 */    if (this.platformName != null) {
/* 48:48 */      TupleData reservedMemory = data
/* 49:49 */        .getTupleData("NativeMemoryLabels.reserved");
/* 50:   */      
/* 51:51 */      if (reservedMemory != null)
/* 52:   */      {
/* 55:55 */        if (!reservedMemory.isEmpty()) {
/* 56:56 */          double maxY = reservedMemory.getMaxY(VGCAxes.MB);
/* 57:57 */          if (maxY > getPlatformLimit() * 0.99D) {
/* 58:58 */            addProblemToNativeAnalysis(data, 
/* 59:59 */              RecommendationLabels.NATIVE_HEAP_EXHAUSTED);
/* 60:   */          }
/* 61:   */        }
/* 62:   */      }
/* 63:   */    }
/* 64:   */  }
/* 65:   */  
/* 66:   */  private int getPlatformLimit()
/* 67:   */  {
/* 68:68 */    if (this.platformName.equalsIgnoreCase("linux"))
/* 69:69 */      return 3072;
/* 70:70 */    if (this.platformName.equalsIgnoreCase("aix"))
/* 71:71 */      return 2816;
/* 72:72 */    if (this.platformName.equalsIgnoreCase("windows")) {
/* 73:73 */      return 2048;
/* 74:   */    }
/* 75:75 */    return -1;
/* 76:   */  }
/* 77:   */}


